
import { ref } from "vue";

function useTodo() {
  const task = ref("");
  const list = ref([]);
  const confirm = () => {
    if (task.value) {
      list.value.push({
        id: Date.now(),
        task: task.value,
      });
      task.value = "";
    }
  };

  const delTodo = (idx) => {
    list.value.splice(idx, 1);
  };

  return {
    task,
    list,
    confirm,
    delTodo
  }
}

export default useTodo;